// 引入request
import request from '../util/request.js';
import config from '../util/config.js';
const machineryRequest = {
    BASE_URL : config.dvUrl + "/dv",
    // 请求过程在这里开发，不在.vue文件中开发
    /**
     * 多条件分页查询toolType列表
     * @param machinery
     * @param callBack
     */
    loadMachinery(machinery, callBack){
        // 拼接url  /sys/queryByPage?xxx
        let url = this.BASE_URL + "/machinery/queryByPage";
        // 调用request进行请求  http://lcation
        request.get(url,machinery,callBack);
    },
    /**
     * 新增设备类型的API
     * @param machinery
     * @param callBack
     */
    addMachinery(machinery,callBack){
        let url = this.BASE_URL + "/machinery/save"
        request.post(url,machinery,callBack);
    },
    /**
     * 通过id加载设备类型信息的API
     * @param tool
     * @param callBack
     */
    getById(machineryId,callBack){
        let url = this.BASE_URL + "/machinery/queryById?machineryId=" + machineryId;
        request.get(url,null,callBack);
    },

    queryMachineryTypeNames(callBack){
        let url = this.BASE_URL + "/machineryType/queryMachineryTypeNames";
        request.get(url,null,callBack);
    },
    queryWorkshopNames(callBack){
        let url = this.BASE_URL + "/workshop/queryWorkshopNames";
        request.get(url,null,callBack);
    },
    /**
     * 修改设备类型信息的API
     * @param tool
     * @param callBack
     */
    updateMachinery(machinery,callBack){
        let url = this.BASE_URL + "/machinery/update";
        request.post(url,machinery,callBack);
    },
    /**
     *  删除设备类型的API
     * @param tool
     * @param callBack
     */
    deleteMachinery(machineryId,callBack){
        request.get(this.BASE_URL + "/machinery/delete?machineryId=" + machineryId,null,callBack);
    },
    /**
     * 批量删除设备类型的API
     * @param toolTypeIds
     * @param callBack
     */
    deleteMachinerys(machineryIds,callBack){
        let url = this.BASE_URL + "/machinery/deletes?a=1";
        for (let i = 0; i < machineryIds.length; i++){
            url += "&machineryIds="+machineryIds[i];
        }
        request.get(url,null,callBack);
    }
}
// 导出我们申明的dictrequest对象
export default machineryRequest;